home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / itelli_1 / aspdat~1.txt < prev   
Encoding:
Text File  |  1998-08-15  |  4.5 KB  |  186 lines

  1. <%Response.buffer = True %>
  2. <html>
  3.  
  4. <head>
  5.  
  6. </head>
  7.  
  8. <body bgColor=#ffffff>
  9.  
  10. <!-- #include virtual="/Inc/adovbs.inc"-->
  11. <%
  12.  
  13. ' Create a Data Connection to the database.  Data connection can be any ODBC database as long as a DSN has been created.
  14.  
  15.  
  16. set oconn = server.CreateObject("ADODB.connection")
  17. oConn.Open "dsn=usedequipsql;uid=sa;pwd=;DATABASE=usedequip" 
  18. SQLtemp="SELECT * from MyDatabaseTable"
  19.  
  20. ' Set the paging parameters.  MyPageSize is the number of records displayed on each page.  we are also checking to see if we should use the SQLtemp string, or the URL encoded SQL string.
  21.  
  22. mypage=request("whichpage")
  23.  
  24. If  mypage="" then
  25.    mypage=1
  26. ' If passing a session variable, include that code here.  Example: If you are calling this ASP from an HTML form that has a field called mydescription.
  27.   'session("mydescription") = Request.QueryString("mydescription")
  28. end if
  29. mypagesize=request("pagesize")
  30. If  mypagesize="" then
  31.    mypagesize=30
  32. end if
  33. mySQL=request("SQLquery")
  34. IF  mySQL="" THEN
  35.    mySQL=SQLtemp
  36. END IF
  37.  
  38. ' Open a recordset and set paging
  39.  
  40. set ors=Server.CreateObject("ADODB.Recordset")
  41. ors.cursorlocation=aduseclient
  42. ors.cachesize=20
  43. ors.open mySQL,oconn
  44. ors.movefirst
  45. ors.pagesize=mypagesize
  46. maxpages=cint(ors.pagecount)
  47. maxrecs=cint(ors.pagesize)
  48. ors.absolutepage=mypage
  49. howmanyrecs=0
  50.  
  51. %>
  52.  
  53. <!-- Create a table to present our data -->
  54.     
  55. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  56.     
  57.     <tr>
  58.         <td align="center" colSpan="6" vAlign="top"><font size="4" face="Arial"><b>My Data Page</b>
  59.             </font>
  60.             
  61.      </tr>
  62.      <tr>
  63.      <td align="center" colspan="6"><font size="3" face="Arial" color="red"> <b><%response.write "Page " & mypage & " of " & maxpages & ""%></b>
  64.  
  65.      </font>
  66.         
  67.     
  68.     
  69.     <tr>        
  70.         <td colspan="6" align="middle" valign="center" cellpadding = "0">  
  71.             
  72.         </td>
  73.     </tr>    
  74.     <tr>
  75.     <th bgcolor="#c0c0c0"><font SIZE="3" FACE="arial" COLOR="#80000" cellpadding = "0">
  76.         Column 1</font> 
  77.     </th>
  78.     <th bgcolor="#c0c0c0"><font SIZE="3" FACE="arial" COLOR="#80000">
  79.         Column 2</font> 
  80.     </th>
  81.     <th bgcolor="#c0c0c0"><font SIZE="3" FACE="arial" COLOR="#80000">
  82.         Column 3</font> 
  83.     </th>
  84.     
  85.     <th bgcolor="#c0c0c0"><font SIZE="3" FACE="arial" COLOR="#80000">
  86.         Column 4</font> 
  87.     </th>
  88.     <th bgcolor="#c0c0c0"><font SIZE="3" FACE="arial" COLOR="#80000">
  89.         Column 5</font> 
  90.     </th>
  91.     <tr><td bgcolor="#000000" colspan="6"></td></td>
  92.     </tr>
  93.     
  94.     <%
  95.     do while not ors.eof and howmanyrecs < maxrecs
  96.     
  97.     ' Check to see what color the row should be.  These colors are light grey, and dark grey.  Color names are not recommended here.
  98.  
  99.     If iswitch = TRUE then
  100.         rcolor = "#c0c0c0"
  101.         iswitch = False
  102.     Else rcolor = "ffffff"
  103.         iswitch = TRUE
  104.     End If 
  105.     
  106.     
  107.     %>
  108.  
  109.         <tr>
  110.         <td align="left" bgcolor=<%=rcolor%>><font SIZE="2" FACE="arial" COLOR="black">
  111.             <%Response.Write "<B>" & ors.fields("DatabaseField1") &"</B>"%></font>
  112.         </td>
  113.             
  114.         <td align="middle" bgcolor=<%=rcolor%>><font SIZE="2" FACE="arial" COLOR="black">
  115.             <%Response.Write ors.fields("DatabaseField2")%> </font>
  116.         </td>
  117.     
  118.         <td align="middle" bgcolor=<%=rcolor%>><font SIZE="2" FACE="arial" COLOR="black">
  119.             <%Response.Write ors.fields("DatabaseField3")%></font>
  120.         </td>
  121.             
  122.         <td align="right" bgcolor=<%=rcolor%>><font SIZE="2" FACE="arial" COLOR="black">
  123.             <%Response.Write ors.fieldS("DatabaseFields4")%></font>
  124.         </td>
  125.             
  126.         <td align="middle" vAlign="center" bgcolor=<%=scolor%>><font color="black">
  127.             <%Response.Write ors.fieldS("DatabaseFields4")%></font>
  128.         </td>
  129. </tr>
  130.         
  131.                     
  132. <%
  133.     
  134. ors.movenext    
  135. howmanyrecs=howmanyrecs+1    
  136. loop
  137.  
  138. %>
  139.     
  140. <!-- Page Control.  Build a table which contains Hyperlinks to each page. -->    
  141.  
  142.     <TR>
  143.     <td align=center colspan="6" bgcolor=SkyBlue><H3>Page Control<h3></td>
  144.     <tr>
  145.     <td align=center colspan="6" bgcolor=SkyBlue><font size="2" face="arial">
  146.     
  147. <%
  148. pad="0"
  149. scriptname=request.servervariables("script_name")
  150.  
  151. %> 
  152.  
  153. <tr>
  154.     <td align=center colspan=6 bgcolor=SkyBlue>
  155.  
  156. <%
  157.    for counter=1 to maxpages
  158.     
  159.    If counter>=25 then
  160.       pad=""
  161.    end if
  162.    
  163.    ref="<font size='2' face='Arial' color='black'><a href='" & scriptname 
  164.    ref=ref & "?whichpage=" & counter
  165.    ref=ref & "&pagesize=" & mypagesize 
  166.    ref=ref & "&sqlQuery=" & server.URLencode(mySQL)
  167.    ref=ref & "'>" & pad & counter & "</a>"
  168.    
  169.    response.write ref & "</font> "
  170.    
  171. next
  172.  
  173.  
  174. %>        
  175.     </font>
  176. </table>
  177.     
  178. <%
  179.     
  180.     ors.close
  181.     set rstemp=nothing
  182.     
  183. %>
  184.     
  185. </body></html>
  186.